#include "stdio.h"
#include "stdlib.h"

typedef int datatype;
typedef struct DLnode
{
	datatype data;
	struct DLnode *next;
	struct DLnode *prior;
} node, *DLink;

DLink init()
{
	DLink L;
	L = (DLink)malloc(sizeof(DLnode));
	if (!L)
	{
		exit(0);
	}
	L->next = NULL;
	L->prior = NULL;
	return L;
}
void creat(DLink L, int n)
{
	for (int i = 0; i < n; i++)
	{
		node *n = (DLnode *)malloc(sizeof(DLnode));
		n->data = i;
		n->next = L->next;
		L->next = n;
		n->prior = L;
	}
}
//删除N号节点
void delte(DLink L, int n)
{
	node *p;
	p = L->next;
	for (int i = 1; i < n; i++)
	{
		p = p->next;
	}
	(p->prior)->next = p->next;
	p->next->prior = p->prior;
	free(p);
}

void output(DLink L)
{
	node *p;
	p = L->next;
	do
	{
		printf("%d\n", p->data);
		p = p->next;
	} while (p);
	printf("\n");
}

void main()
{
	DLink L;
	L = init();
	creat(L, 5);
	output(L);
	delte(L, 2);
	output(L);
}